<template>
	<view class="classifylist">
		<Hearder :name="'分类列表'"></Hearder>
		<view class="shop_list">
			<view class="every" v-for="item in shoplist" :key="item.goods_id" @click="toPage('/pages/classify/goodsdet?id='+item.goods_id)">
				<image :src="item.goods_image"></image>
				<view class="every_bot">
					<view class="title">{{item.goods_name}}</view>
					<view class="price-con">￥{{item.goods_min_price}}</view>
				</view>
			</view>
		</view>
		<view class="nidata" v-if="shoplist.length==0">
			<image src="../../static/images/noimg.png"></image>
		</view>
		<!-- 底部加载提示 -->
		<view class="uni-loadmore" v-if="showLoadMore">{{loadMoreText}}</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				shoplist:[],
				id:'',
				page:1,
				loadMoreText: "加载中...",
				showLoadMore: false,
				last_page:1
			}
		},
		onReachBottom() {
			this.last_page = this.last_page + 1
			if (this.last_page > this.page) {
				this.loadMoreText = "没有更多数据了!"
				return;
			}
			this.showLoadMore = true;
			this.getinit()
		},
		onLoad(options) {
			this.id = options.id || this.$route.query.id
			this.getinit()
		},
		methods:{
			getinit(){
				this.request('/goods/getCategoryGoodsList',{category_id:this.id,page:this.page}).then(res => {
					if(res.data.code==1){
						this.shoplist = this.shoplist.concat(res.data.data.data)
						this.last_page = res.data.data.last_page
					}
				})
			},
			toPage(route){
				uni.navigateTo({
				    url: route
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.classifylist{
		min-height: 100%;
		background: $uni-background-color;
		.shop_list{
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;
			padding: 0 4% 30rpx;
			.every{
				overflow: hidden;
				width: 335rpx;
				margin-top: 30rpx;
				border-radius: 10rpx;
				background: #fff;
				image{
					width: 100%;
					height: 335rpx;
				}
				.every_bot{
					padding: 0 20rpx;
					.title{
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp:2;
						/*! autoprefixer: off */
						-webkit-box-orient: vertical;
						/* autoprefixer: on */
						line-height: 34rpx;
						font-size: 26rpx;
						margin-top: 20rpx;
						height: 70rpx;
					}
					.price-con{
						color: $uni-text-color;
						font-weight: 800;
						margin-left: -4rpx;
						padding: 18rpx 0;
					}
				}
			}
		}
	}
</style>